﻿using System;
using Reflector.CodeModel;

namespace CallGraphExtractor.CecilAdapter
{
    class AssemblyReference : IAssemblyReference
    {
        #region Fields

        private Mono.Cecil.AssemblyNameReference mAssemblyNameReference;

        #endregion Fields

        #region Lifecycle

        public AssemblyReference(Mono.Cecil.AssemblyNameReference assemblyNameReference)
        {
            mAssemblyNameReference = assemblyNameReference;
        }

        #endregion Lifecycle

        #region IAssemblyReference Members

        public IModule Context
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string Culture
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public byte[] HashValue
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public string Name
        {
            get { return mAssemblyNameReference.FullName; }//TODO verify
            set { throw new NotSupportedException(); }
        }

        public byte[] PublicKey
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public byte[] PublicKeyToken
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public IAssembly Resolve()
        {
            string location =
                System.Reflection.Assembly.ReflectionOnlyLoad(mAssemblyNameReference.FullName).Location;
            return new Assembly(Mono.Cecil.AssemblyDefinition.ReadAssembly(location), null);
        }

        public bool Retargetable
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public Version Version
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        #endregion

        #region IComparable Members

        public int CompareTo(object obj)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
